"""drf URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.1/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path,include
from aaa import old_views
from aaa.views.role import rolesView
from aaa.views.user import userInfoView
from aaa.views.rights import rightsView
from django.conf.urls import url
from rest_framework import routers
router = routers.DefaultRouter()
router.register(r'users',userInfoView)
router.register(r'roles',rolesView)
router.register(r'rights',rightsView)

urlpatterns = [
    url(r'^(?P<version>[v1|v2]+)/auth/', old_views.authView.as_view()),
    url(r'^(?P<version>[v1|v2]+)/order/', old_views.orderView.as_view()),
    url(r'^(?P<version>[v1|v2]+)/roles/delete/(?P<roleId>\d+)/rights/(?P<rightId>\d+)', old_views.removeRightView.as_view()),
    url(r'^(?P<version>[v1|v2]+)/menus/', old_views.menuView.as_view()),
    url(r'^(?P<version>[v1|v2]+)/role_display/', old_views.getRolesView.as_view()),
    url(r'^(?P<version>[v1|v2]+)/rights/tree', old_views.rightsTreeView.as_view()),
    url(r'^(?P<version>[v1|v2]+)/roles/(?P<roleId>\d+)/rights', old_views.allotRightsView.as_view()),
    # url(r'^(?P<version>[v1|v2]+)/users/(?P<pk>\d+)$', views.userInfoView.as_view(),name='users'),
    # url(r'^(?P<version>[v1|v2]+)/users/$', old_views.userInfoView.as_view({'get': 'list'})),
    url(r'^(?P<version>[v1|v2]+)/roles/$', rolesView.as_view({'get': 'list','post':'create'})),
    # url(r'^(?P<version>[v1|v2]+)/roles/(?P<pk>\d+)/$', rolesView.as_view({'get': 'retrieve','delete':'destroy','put':'update','patch':'partial_update'})),
    url(r'^(?P<version>[v1|v2]+)/',include(router.urls)),
    url(r'^(?P<version>[v1|v2]+)/login/', old_views.loginView.as_view())
    # url(r'v1/login/', old_views.login)
]